package com.camel.chart.utils.entity;

import lombok.Data;

import java.io.Serializable;

@Data
public class ChartNetWorkInterface implements Serializable {


    private String disPlayName;

    private String inetAddress;

    private String broadcastAddress;

    @Override
    public String toString() {
        return "{" +
                "名称: '" + disPlayName + '\'' +
                ", 地址: '" + inetAddress + '\'' +
                '}';
    }

    private static final long serialVersionUID = 1L;

    public byte[] getBroadCastAddressAsByteArray()  {
        String ip = this.getBroadcastAddress();
        String[] ii = ip.split("\\.");
        byte[] ips = new byte[4];
        for (int i = 0; i < 4; i++) {
            ips[i] = (byte) (Integer.parseInt(ii[i]));
        }
        return ips;
    }

    public String getBroadCastAddressAsString()  {
        return this.getBroadcastAddress();
    }

    public byte[] getLocalIP() {
        String ip = this.getInetAddress();
        String[] ii = ip.split("\\.");
        byte[] ips = new byte[4];
        for (int i = 0; i < 4; i++) {
            ips[i] = (byte) (Integer.parseInt(ii[i]));
        }
        return ips;
    }

    public String getLocalIPStr() {
        return this.getInetAddress();
    }
}
